unsigned int x1,i;
/*void pwm_gen()
{
  for(x1=0;x1<4;x1++)
   {
	P1OUT ^= 0x31; 		  // green LED on
	i=rand();
	_delay_cycles(i);
	P1OUT ^= 0x10; 		  // green LED on
	_delay_cycles(i);
	P1OUT ^= 0x20; 		  // green LED on
	_delay_cycles(i);
   }
}*/

unsigned int x1;
void pwm1()
{
	P1OUT ^= 0x31; 		  // green LED on
	_delay_cycles(100000);
	P1OUT ^= 0x10; 		  // green LED on
	_delay_cycles(60000);
	P1OUT ^= 0x20; 		  // green LED on
	_delay_cycles(40000);
	P1OUT ^= 0x31; 		  // green LED on
	_delay_cycles(50000);
	P1OUT ^= 0x01; 		  // green LED on.
	_delay_cycles(500);
	P1OUT ^= 0x31; 		  // green LED on
	_delay_cycles(50);
	P1OUT ^= 0x00; 	
	P1OUT ^= 0x01; 		  // green LED on
	_delay_cycles(300000);
	P1OUT ^= 0x31; 	
	_delay_cycles(2000);
	P1OUT ^= 0x20; 	
	_delay_cycles(10000);
	P1OUT ^= 0x31; 	
	_delay_cycles(40000);
	P1OUT ^= 0x01; 	
	_delay_cycles(100000);
	P1OUT ^= 0x00; 	
}
void led2_fade()
{
	P1OUT ^= 0x10; 		  // green LED on
	_delay_cycles(1000);
	P1OUT ^= 0x20; 		  // green LED on
	_delay_cycles(3000);
	P1OUT ^= 0x01; 		  // green LED on
	_delay_cycles(600);
}
	void led3_fade()
{
	P1OUT ^= 0x20; 		  // green LED on
	_delay_cycles(600);
	P1OUT ^= 0x01; 		  // green LED on
	_delay_cycles(1000);
	P1OUT ^= 0x10; 		  // green LED on
	_delay_cycles(900);
}
	void led4_fade()
{
	P1OUT ^= 0x01; 		  // green LED on
	_delay_cycles(3000);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(70000);
}
		
void led5_fade()
{
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(90);
	P1OUT ^= 0x10; 		  // green LED on
	_delay_cycles(20000);
}

void pwm_gen()
{
for(x1=0;x1<3;x1++)
   {
   	pwm1();
   	_delay_cycles(8000);
   }
  for(x1=0;x1<4;x1++)
   {
   	led2_fade();
   	_delay_cycles(400);
   }
 
  for(x1=0;x1<3;x1++)
   {
   	led3_fade();
   	_delay_cycles(2000);
   }
  for(x1=0;x1<2;x1++)
   {
   	led5_fade();
   	_delay_cycles(600);
   }
  for(x1=0;x1<1;x1++)
   {
   	pwm1();
   	_delay_cycles(50);
   }
   for(x1=0;x1<5;x1++)
   {
   	pwm1();
   		_delay_cycles(500000);
   }
 for(x1=0;x1<5;x1++)
   {
   	led2_fade();
   		_delay_cycles(50);
   }
 for(x1=0;x1<4;x1++)
   {
   	led2_fade();
   		_delay_cycles(500);
   }
 for(x1=0;x1<3;x1++)
   {
   	led2_fade();
   		_delay_cycles(580);
   }
 for(x1=0;x1<2;x1++)
   {
   	led2_fade();
   		_delay_cycles(9500);
   }
  for(x1=0;x1<1;x1++)
   {
   	led3_fade();
   		_delay_cycles(500);
   }
    for(x1=0;x1<1;x1++)
   {
   	led4_fade();
   	_delay_cycles(1060);
   }
   for(x1=0;x1<1;x1++)
   {
   	led5_fade();
   	_delay_cycles(1000);
   }  	
}

void pwm2()
 {
  	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(100000);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(5000);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(900);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(300000);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(500000);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(12005);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(50080);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(6000);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(400000);
	P1OUT ^= 0x30; 		  // green LED on
	_delay_cycles(50000);
	P1OUT ^= 0x31; 		  // green LED on
	_delay_cycles(500000);	
 } 
